package com.saianfu.flowable.demo.listener

import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType
import org.flowable.common.engine.api.delegate.event.FlowableEvent
import org.flowable.common.engine.api.delegate.event.FlowableEventListener


class ASFlowEventListener : FlowableEventListener {
    override fun onEvent(event: FlowableEvent) {
        when (event.type) {
            FlowableEngineEventType.JOB_EXECUTION_SUCCESS -> {
                println("A job well done!")
            }
            FlowableEngineEventType.JOB_EXECUTION_FAILURE -> {
                println("A job has failed...")
            }
            else -> {
                println("Event received: ${event.type}")
            }
        }
    }

    override fun isFailOnException(): Boolean {
        return false
    }

    override fun isFireOnTransactionLifecycleEvent(): Boolean {
        return true
    }

    override fun getOnTransaction(): String {
        return "getOnTransaction"
    }
}